-- =========================================================================================
-- 				PROTECT THE VIP - Gamemode by SteveUK
--  You are free to make modifications and redistributions of this gamemode as long as I'm credited for it
--=========================================================================================

-- this is mainly adding stuff to the player meta table, tis cool
local PlayerExt = FindMetaTable( "Player" )
if ( !PlayerExt ) then
	MsgAll( "CRITICAL ERROR: PLAYER META TABLE NOT FOUND!!! For PlayerExt." )
	return
end

-- stance helper functions
function PlayerExt:Running( )
	if( self:KeyDown( IN_RUN ) == true and self:IsCrouchJumping() == false and self:IsOnGround() == true ) then
		return true
	else
		return false
	end
end

function PlayerExt:Walking( )
	
	if( self:GetVelocity():Length() > 0 and self:KeyDown( IN_RUN ) == false ) then
		return true
	end
	
	return false
	
end

function PlayerExt:CrouchJumping( )
	
	if( self:IsOnGround() == true and self:Crouching() ) then
		return true
	end
	
	return false
end

-- do the default loadout for the player
function PlayerExt:DoLoadout( )

end

-- get primary weapon
function PlayerExt:GetPrimaryWeapon( )
	return self.PrimaryWeapon
end

-- get secondary weapon
function PlayerExt:GetSecondaryWeapon( )
	return self.SecondaryWeapon
end

-- can pickup a weapon (checks if they're a VIP or if they have both of their slots full
function PlayerExt:CanPickupWeapon( )

	if( !self.PrimaryWeapon or !self.SecondaryWeapon ) then
		return true
	else
		return false
	end
	
end

-- routine for picking/being given a weapon Params: weapon, weapon type (pri, sec, nade)  - Weap types: 0 = auto, 1 = pri, 2 = sec, 3 = nade,
function PlayerExt:SetupWeapon( weapon, wtype )

	if( wtype == 0 ) then -- automatic
		if( weapon:IsGrenade() == true ) then
			wtype = 3
		else
			if( !self.PrimaryWeapon ) then
				wtype = 1
			else
				wtype = 2
			end
		end
	end
	
end
